<!doctype html>
<html>
	<head>
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
		<title>专享服务</title>
		<link href="../../css/newStyle.css" type="text/css" rel="stylesheet" />
		<script type="text/javascript" src="../../js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script type="text/javascript" src="../../js/gbRst.js"></script>
		<script type="text/javascript" src="../../js/utils.js"></script>
		<script type="text/javascript" src="../../js/header&footer.js"></script>
		<script type="text/javascript" src="../../js/check.js"></script>
		<script type="text/javascript" src="../../js/qmsk-1.2.js"></script>
		<script type="text/javascript" src="../../js/openId.js"></script>
		<script type="text/javascript">
			$(function() {
				hasData()
				getService()
			})
			function cq() {
				hasData()
				$("#fs").removeClass("focus")
				$("#cq").addClass("focus")
				$("#info2").hide()
				$("#info").show()
				getService()
			}

			function fs() {
				hasData()
				//$("#info").empty()
				$("#cq").removeClass("focus")
				$("#fs").addClass("focus")
				$("#info").hide()
				$("#info2").show()
				getServiceConsume()
			}

			function getService() {
				$("#ownService").empty()
				new qmsk.SiglePinterest({
					url : '../../../memberExclusiveService/find/memberOwnServiceList', // 请求地址，插件会自动在 url 后追加 /n/n
					initPage : 1, // 首次加载页数
					size : 10, // 每次加载数量，即每页的大小
					success : loadService, // 成功回调
					valves : 100, //当滚动条距离底部该像素的时候加载
					data : {
						'shopId' : _shopId,
						'openId' : _openId
					},
					loading : addRefresh2,
					loaded : delRefresh,
					emptyHandler : noSerResult

				});
			}

			function loadService(dt) {
				for (var i = 0; i < dt.row; i++) {
					var htm = "<tr>"
					htm += "<td>" + dt.getValue("name", i) + "</td>"
					var nums = dt.getValue("nums", i)
					var useNums = dt.getValue("useNums", i)
					var status = dt.getValue("status", i)
					var UneffectDate = dt.getValue("UneffectDate", i)
					if (nums == 0) {
						htm += "<td>无限制</td>"
						htm += "<td>无限制</td>"
						if (status == 1) {
							htm += "<td>" + UneffectDate.substring(0, 10) + "</td>"
						} else {
							htm += "<td>已失效</td>"

						}
					} else {
						htm += "<td>" + nums + "</td>"
						htm += "<td>" + parseInt(nums - useNums) + "</td>"
						if (nums > useNums) {
							if (status == 1) {
								htm += "<td>" + UneffectDate.substring(0, 10) + "</td>"
							} else {
								htm += "<td>已失效</td>"

							}
						} else {
							htm += "<td>服务次数已用完</td>"
						}
					}

					htm += "</tr>"
					$("#ownService").append(htm)
				}
			}

			function getServiceConsume() {
				$("#serviceConsume").empty()
				new qmsk.SiglePinterest({
					url : '../../../memberExclusiveServiceConsume/find/memberExclusiveServiceConsumeList', // 请求地址，插件会自动在 url 后追加 /n/n
					initPage : 1, // 首次加载页数
					size : 10, // 每次加载数量，即每页的大小
					success : loadServiceConsume, // 成功回调
					valves : 100, //当滚动条距离底部该像素的时候加载
					data : {
						'shopId' : _shopId,
						'openId' : _openId
					},
					loading : addRefresh2,
					loaded : delRefresh,
					emptyHandler : noOverResult

				});
			}

			function loadServiceConsume(dt) {
				for (var i = 0; i < dt.row; i++) {
					var htm = "<tr>"
					htm += "<td>" + dt.getValue("name", i) + "</td>"
					htm += "<td>" + dt.getValue("createFileTime", i) + "</td>"
					htm += "</tr>"
					$("#serviceConsume").append(htm)
				}
			}

			function noSerResult() {
				$("#noResult").find(".Datatips").text("暂无服务！");
				$("#noResult").show();
			}//无服务

			function noOverResult() {
				$("#noResult").find(".Datatips").text("暂无已使用服务！");
				$("#noResult").show();
			}//无使用

			function hasData() {
				$("#noResult").hide();
			}//有数据
		</script>
	</head>

	<body>
		<div class="wrapper" style="padding-bottom:30px;">
			<div class="container">
				<div class="placeTit">
					<a href="javascript:history.go(-1)" class="back"></a>专享服务
				</div>
				<div class="tabChange">
					<ul>
						<li class="focus" id="cq" onclick="cq()">
							专享服务
						</li>
						<li id="fs" onclick="fs()">
							已使用
						</li>
					</ul>
				</div>
				<div class="boxTab" style="display:block;" id="info">
					<table class="tb1" width="100%" cellspacing="1" cellpadding="0" border="0">
						<thead>
							<tr>
								<th>服务项目</th>
								<th>享有次数</th>
								<th>剩余次数</th>
								<th>有效期</th>
							</tr>
						</thead>
						<tbody id="ownService"></tbody>
					</table>
				</div>
				<div class="boxTab" id="info2">
					<table class="tb1" width="100%" cellspacing="1" cellpadding="0" border="0">
						<thead>
							<tr>
								<th>服务项目</th>
								<th>时间</th>
							</tr>
						</thead>
						<tbody id="serviceConsume"></tbody>
					</table>
				</div>
				<div class="noData" id="noResult" style="display:none;">
					<p class="Datatips"></p>
				</div>
			</div>
		</div>
	</body>
</html>
